<?php
session_start();
include '../include/Mysql.Class.php';
include '../include/config.php';
?>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<?php
$username = $_POST['username'];
$userpwd = $_POST['userpwd'];
$newpwd = $_POST['newpwd'];
//echo $username."--".$userpwd."--".$newpwd;
if($userpwd==$_SESSION['pwd']){
	$userpwd = md5(trim($userpwd));
	$newpwd = "serviceStationPwd='".md5(trim($newpwd))."'";
	$mysql = new mysql($mydbhost, $mydbuser, $mydbpw, $mydbname, $conn, $mydbcharset);
	$mysql->update("servicestation",$newpwd,"serviceStationId='".$username."' and serviceStationPwd='".$userpwd."'");
	//当更新成功后，修改保存在session中密码值
	$_SESSION['pwd'] = $_POST['newpwd'];
	//echo $username."--".$userpwd."--".$newpwd."--"."修改密码成功!";
	echo "<script language='javascript'>alert('修改密码成功!');window.location.href='editPwd.php';</script>";
}else{
	//echo $username."--".$userpwd."--".$newpwd."--"."原密码错误!";
	echo "<script language='javascript'>alert('原密码错误!');window.location.href='editPwd.php';</script>";
}
?>
</body>
</html>